<?php
$this->title = "价格优势";
$this->registerCss("
        html, body {
            position: relative;
            height: 100%;
        }
        body {
            background: #eee;
            font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
            font-size: 14px;
            color:#000;
            margin: 0;
            padding: 0;
        }
        .swiper-container {
            width: 100%;
            height: 559px;
            margin-left: auto;
            margin-right: auto;
        }
        .swiper-slide {
            text-align: center;
            font-size: 18px;
            background: #fff;
        }
        .product-item{position: relative;}
        .product-item:hover .mengban{display:block;}
        .service-item:hover .service-item-thumb{border-radius: 50%;box-shadow: 0 0 27px #333}
        input{width:100%;height:52px;background: #fff;border:0px;outline: none;border-radius: 6px;padding-left: 15px;font-size: 16px}
        .mengban{display: none;position: absolute;width:100%;height:100%;top:0px;left:0px;align-items: center;padding: 16px 20px 24px 20px;}
        .mengban-inner{background:rgba(0,0,0,0.4);width:100%;height:100%;}
        .contact-model{position: fixed;left:50%;top:50%;background: rgba(255,255,255,1);transform: translate(-50%,-50%);z-index: 9999;padding: 50px 60px 35px 60px;text-align: center;display: none;width:560px;}
        .layui-layer-lan .layui-layer-title {
            background:rgb(58, 65, 78) !important;
        }
        .layui-layer-rim .layui-layer-btn a {
            height: 40px !important;
            line-height: 40px !important;
            padding: 0 42px !important;
        }
        .layui-layer-rim .layui-layer-btn {
            text-align: center !important;
        }
");
$setting = Yii::$app->setting;
?>
<link href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/animate.css/3.7.0/animate.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/layer/2.3/skin/layer.css" rel="stylesheet">

<div class="Home-default-index">

    <div class="sec-one" style="padding: 200px 12%;background: url(<?=$setting->get('price_header_bg')?>) no-repeat center;background-size: cover">
        <p style="color: #fff;font-size: 36px;letter-spacing: 1px;margin-bottom: 0px">网站价格方案</p>
        <p style="color: #fff;font-size: 16px;letter-spacing: 1px;margin-bottom: 0px;margin-top: 30px;font-weight:300">为您量身定制，总有一款适合您</p>
    </div>
    
    <div class="sec-two" style="padding: 0 12%;margin: 50px 0px">
        <img src="<?=$setting->get('price_img')?>" alt="" style="width:100%">
    </div>

    <div class="sec-eight" id="contact" style="padding: 100px 12% 100px 12%;background: url('https://other3.oss-cn-beijing.aliyuncs.com/13network/footerbg2x.png') no-repeat center;background-size: cover;">
        <div style="display: flex;" class="wow zoomIn" data-wow-duration="1s">
            <div style="flex: 1">
                <div class="contact-box" style="background: #fff;padding: 72px;height:429px">
                    <p style="color: #333;font-size: 27px;letter-spacing: 1px;margin-bottom: 0px">联系我们</p>
                    <div style="height:1px;width:100px;background-color: #333333;margin: 20px 0px"></div>
                    <p style="font-weight: 300;font-size: 16px;color:#333;letter-spacing: 1px;">提交您的信息，我们会第一时间与您联系！</p>
                    <p style="margin-top: 50px"><span class="glyphicon glyphicon-earphone" style="color:#31373B;margin-right: 15px"></span><a href="tel:<?=$setting->get('contact_phone')?>" style="color: #777777"><?=$setting->get('contact_phone')?></a></p>
                    <p style="color:#777;margin-top: 32px"><span class="glyphicon glyphicon-map-marker" style="color:#31373B;margin-right: 15px"></span><?=$setting->get('contact_location')?></p>
                    <p style="margin-top: 32px"><span class="glyphicon glyphicon-envelope" style="color:#31373B;margin-right: 15px"></span><a href="mailto:<?=$setting->get('contact_email')?>" style="color: #777777"><?=$setting->get('contact_email')?></a></p>
                </div>
            </div>
            <div style="flex: 1">
                <div class="from-box" style="background: #3A414E;padding: 72px;height:429px">
                    <div class="from-item">
                        <input type="text" name="username" id="username" placeholder="请填写您的姓名" style="">
                    </div>
                    <div class="from-item" style="margin-top: 20px">
                        <input type="text" name="phone" id="phone" placeholder="请填写您的联系电话" style="">
                    </div>
                    <div class="from-item" style="margin-top: 20px">
                        <textarea id="question" style="width:100%;height:100px;padding: 15px;outline: none;border: 0px;background: #fff;border-radius: 6px;font-size: 16px;" placeholder="请填写您咨询的问题，以便客服与您高效沟通"></textarea>
                    </div>
                    <div style="margin-top: 20px">
                        <button class="btn-submit" style="background: unset;border: 0px;outline: none;"><img src="https://other3.oss-cn-beijing.aliyuncs.com/13network/waibaobtn-2x.png" style="width:150px"></button>
                    </div>


                </div>
            </div>
        </div>
    </div>

</div>

<div class="contact-model">
    <p style="color:#333;font-size: 32px;">十年企业网站制作经验</p></p>
    <p style="color:#333;font-size: 32px;">数千家网站建设案</p>
    <div style="display: flex;align-items: center;margin-top: 40px">
        <div style="flex: 1">
            <a href="#contact" class='maodian'>
                <img src="https://other3.oss-cn-beijing.aliyuncs.com/13network/tianxieyixiang.png" style="width:90%">
            </a>
        </div>
        <div style="flex: 1">
            <img class="contact-model-cancel" src="https://other3.oss-cn-beijing.aliyuncs.com/13network/zanbuxuyao.png" style="width:90%">
        </div>
    </div>
    <div style="display: flex;align-items: center;margin-top: 20px;color:#3079E3;font-size: 14px">
        <div style="flex: 1">响应式网站</div>
        <div style="flex: 1">html5网站</div>
        <div style="flex: 1">SEO优化</div>
        <div style="flex: 1">网站运维</div>
    </div>
</div>

<div class="contact-qq" style="position: fixed;top:54%;right:0px;z-index: 9999">
    <div>
        <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=<?=$setting->get('contact_qq')?>&site=qq&menu=yes">
            <img src="https://other3.oss-cn-beijing.aliyuncs.com/13network/jishuzhichi2x.png" style="width:100px;">
        </a>
    </div>

    <div class="contact-phone">
        <a href="#contact" class='maodian'>
            <img src="https://other3.oss-cn-beijing.aliyuncs.com/13network/lianxidianhua2x.png" style="width:100px;">
        </a>
    </div>
    
</div>

<script src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
<script src="https://cdn.bootcss.com/wow/1.1.2/wow.min.js"></script>
<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<script type="text/javascript">

    new WOW().init();

    // setTimeout(function(){
    //     $('.contact-model').fadeIn(500);
    // },2500)

    $('.contact-model-cancel').click(function(){
        $('.contact-model').fadeOut(500);
    });

    $(".maodian").bind("click touch",function(){
        //根据a标签的href转换为id选择器，获取id元素所处的位置，并高度减50px（这里根据需要自由设置）
        $('html,body').animate({scrollTop: ($($(this).attr('href')).offset().top -50 )},500);

        $('.contact-model').fadeOut(500);
    });



    $('.btn-submit').click(function(){

        // 用户名
        var username = $('#username').val();
        if(!username){
            myalert('用户名，请填写');
            return;
        }
        // 电话
        var phone = $('#phone').val();
        if(phone.indexOf("-") != -1){
            if(!checkTel(phone)){
                return;
            }
        }else{
            if(!checkPhone(phone)){
                return;
            }
        }
        // 问题
        var question = $('#question').val();
        if(!question){
            myalert('咨询的问题，请填写');
            return;
        }

        var randnumOne = Math.ceil(Math.random()*20);
        var randnumTwo = Math.ceil(Math.random()*20); 

        var yanzheng =  layer.open({
          title:'验证提交',
          type: 1,
          skin: 'layui-layer-rim', //加上边框
          area: ['420px', '200px'], //宽高
          btn: ['提交'],
          yes: function(index, layero){
               var num = $('#num').val();
             
               var total = randnumOne + randnumTwo;
               if(num == total){
                    submit(yanzheng);
               }else{
                    myalert('结果不能为空或不正确',yanzheng);
               }
          },
          content: '<p style="text-align:center;margin-top:20px;"><input type="text" id="num" placeholder="'+randnumOne+'+'+randnumTwo+'=?" style="border:1px solid #333;width:80%;"></p>'
        });

    });
    function myalert(msg,closeobj){
        var myself = layer.alert(msg, {
          title:'错误信息',
          skin: 'layui-layer-lan' //样式类名
          ,closeBtn: 0
        }, function(){
            layer.close(closeobj);
            layer.close(myself);
        });
    }

    function submit(closeobj){

        // 用户名
        var username = $('#username').val();
        if(!username){
            myalert('用户名，请填写');
            return;
        }
        // 电话
        var phone = $('#phone').val();
        if(phone.indexOf("-") != -1){
            if(!checkTel(phone)){
                return;
            }
        }else{
            if(!checkPhone(phone)){
                return;
            }
        }
        // 问题
        var question = $('#question').val();
        if(!question){
            myalert('咨询的问题，请填写');
            return;
        }

        $.ajax({
            type: 'POST',
            url: "/home/default/consult",
            data:{
                usename : username,
                phone    : phone,
                question : question,
            },
            dataType: 'json',
            success: function(res){
                layer.close(closeobj);
                if(res.code == 200){
                    layer.msg('提交成功');
                }else{
                    myalert(res.message);
                }
            },
            error:function (error) {
                console.log(error)
            }
        })
    }

    function checkPhone(phone){ 
        if(!(/^1[34578]\d{9}$/.test(phone))){ 
            myalert('手机号码有误，请重填') 
            return false; 
        } else {
            return true; 
        }
    }

     function checkTel(tel){
        if(!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/.test(tel)){
            myalert('固定电话有误，请重填') 
            return false;
        }else {
            return true; 
        }
    }


</script>
